#!/usr/bin/perl
use warnings;
use strict;
use Test::More tests => 9;
use Data::Dumper;

BEGIN{
	use_ok( 'Data::Form::Field::Boolean');
}

can_ok('Data::Form::Field::Boolean',
	qw/ id default boolean value errors label input_hint help readonly required valid many/);

can_ok('Data::Form::Field::Boolean', qw/validate validate_custom get add/);

my $field = Data::Form::Field::Boolean->new(
					 name		=> 'checkbox',
					 label   		=> 'I love this thing',
					 boolean	=> {true => 'Y', false => 'N'},
					 default		=> 'true',
	);


isa_ok( $field, 'Data::Form::Field::Boolean');
is( $field->value,$field->boolean->{true}, 'Field has correct default');
is( $field->valid,1, 'Field is valid');

$field->fill_in('N');

is( $field->value,'N', 'Field has correct false value');

$field->fill_in();

is( $field->value,$field->boolean->{false}, 'fill_in with no value is false');
is( $field->valid,1, 'field is still valid');